$(document).ready(function () {
    //contact branches div adjustments
    $(".contactBranchSelectMainLink").click(function (e) {

        if ($(".contactBranchSelectContent").is(':hidden')) {
            $(".contactBranchSelectContent").slideDown('fast');
        }
        else {
            $(".contactBranchSelectContent").slideUp(200);
        }
        $('body').one('click', function () {
            $(".contactBranchSelectContent").slideUp(200);
        });
        e.stopPropagation();
    });
    //Writing the selected contact branches to div header.
    $(".contactBranchSelectContent li a").click(function () {
        var contactSpanValue = $(this).children("span").text()
        $("span.contactBranchSelectSpan").text(contactSpanValue);

    });

    $(".contactBranchSelectContent a").click(function (e) {

        var currentContactCity = $(this).parents("li").attr("class");
        currentContactCity = currentContactCity.substring(15, currentContactCity.indexOf(" "));      
        $("#BranchName").val(currentContactCity);
        var currentContentCityFinal = (".contactContentDiv_" + currentContactCity);
        var currentContentCityFinalContent = (".contactContentDiv_" + currentContactCity + " .contactMainRightPermanentBox");
        var currentContentCityFinalContentCopy = (".contactContentDiv_" + currentContactCity + " .contactMainRightPermanentBox .copyDivContent");
        var pasteDivImg = ('<img src="/content/themes/default/img/content/blackPhoneIcon.jpg" />')

        $(".contactMainRightPermanentBox").children().fadeOut(100)
        $(".contactMainRightPermanentBox").delay(100).fadeOut(100)
        $(".contactContentDivCity").delay(200).fadeOut(100).removeClass("display");
        $(".contactMainRight").find(".contactContentDiv_" + currentContactCity).delay(300).fadeIn(100);
        $(".contactMainRightPermanentBox").children().delay(400).fadeIn(200);
        $(".contactMainRightPermanentBox").delay(400).fadeIn(200);

        e.preventDefault();
        $(".pasteDivContent").html($(currentContentCityFinalContentCopy).html())
        $(pasteDivImg).prependTo(".pasteDivContent span");
       
    });
	$(".contactCityDiv_london a").click();
});




